
import os
import sys
import pytest
from loguru import logger
import time

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
if sys.platform == "win32":
    reportjson_dir = os.path.join(BASE_DIR, 'report/json').replace('/', '\\')
    reporthtml_dir = os.path.join(BASE_DIR, 'report/html').replace('/', '\\')
else:
    reportjson_dir = os.path.join(BASE_DIR, 'report/json')
    reporthtml_dir = os.path.join(BASE_DIR, 'report/html')

logger.add('./log/{time}.log', rotation='20 MB', retention='1 week', encoding='utf-8')

#生成allure报告
pytest.main(['-s', r"--alluredir={}".format(reportjson_dir), "--clean-alluredir"])
os.system('allure generate {} -o {} -c'.format(reportjson_dir,reporthtml_dir))
